import Layout from '@/layout'

//  定义异步路由跳转地址
// 权限管理
const Permission = () => import('@/views/acl/permission/list')
const Role = () => import('@/views/acl/role/list')
const User = () => import('@/views/acl/user/list')
const RoleAuth = () => import('@/views/acl/role/roleAuth')
// 商品管理
const Attr = () => import('@/views/product/attr/list')
const Trademark = () => import('@/views/product/trademark/list')

/* 
常量路由
包括登陆/404/首页
*/
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard'),
      meta: { title: '首页', icon: 'dashboard' }
    }]
  },
]

// 异步路由
export const asyncRoutes = [
  // 权限管理
  {
    name: 'Acl',
    path: '/acl',
    component: Layout,
    redirect: '/acl/role/list',
    meta: {
      title: '权限管理',
      icon: 'el-icon-lock'
    },
    children: [
      {
        name: 'Role',
        path: 'role/list',
        component: Role,
        meta: {
          title: '角色管理'
        }
      },
      {
        name: 'RoleAuth',
        path: 'role/roleAuth/:id',
        component: RoleAuth,
        meta: {
          title: '分配权限'
        }
      },  
      {
        name: 'User',
        path: 'user/list',
        component: User,
        meta: {
          title: '用户管理'
        }
      },  
      {
        name: 'Permission',
        path: 'permission/list',
        component: Permission,
        meta: {
          title: '菜单管理'
        }
      }
    ]
  },
  // 商品管理
  {
    name: "Product",
    path: '/product',
    component: Layout,
    redirect: '/product/trademark/list',
    meta: {
      title: '商品管理',
      icon: 'shop'
    },
    children: [
      {
        name: 'Trademark',
        path: 'trademark/list',
        component: Trademark,
        meta: {
          title: '品牌管理'
        }
      },
      {
        name: 'Attr',
        path: 'attr/list',
        component: Attr,
        meta: {
          title: '平台属性管理'
        }
      }
    ]
  }
]

//任意路由
export const anyRoute = {
  path: '/:pathMatch(.*)',
  name: 'Any',
  redirect: '/404',
  meta: {
    hidden: true
  }
}